package com.test.com.bluetoothchatandroid.adapter;

import com.test.com.bluetoothchatandroid.R;
import com.test.com.bluetoothchatandroid.entity.ChatInfo;

/**
 * Created by ${cs} on 2018/4/23.
 * @author saviorT
 */

public class MyChatAdapter extends EasyRecyclerViewAdapter{


	@Override
	public int[] getItemLayouts() {
		return new int[]{
				R.layout.item_chat_info_left,
				R.layout.item_chat_info_right
		};
	}

	@Override
	public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
		ChatInfo temp = getItem(position);
		if (temp == null){
			return;
		}
		if (temp.isSend()){
			viewHolder.setText(R.id.item_chat_right_msg,temp.getMessage().getMsgContent());
			viewHolder.setText(R.id.item_chat_right_time,temp.getSendTime());
			viewHolder.setText(R.id.item_chat_right_name,temp.getFriendInfo().getFriendNickName());
		}else {
			viewHolder.setText(R.id.item_chat_left_msg,temp.getMessage().getMsgContent());
			viewHolder.setText(R.id.item_chat_left_time,temp.getReceiveTime());
			viewHolder.setText(R.id.item_chat_left_name,temp.getFriendInfo().getFriendNickName());
		}

	}

	@Override
	public int getRecycleViewItemType(int position) {
		ChatInfo temp = getItem(position);
		if (temp.isSend()){return 0;}
		return 1;
	}
}
